// app.js
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      // v = this ;
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        if (res.code) {
          wx.request({
            url: 'https://api.weixin.qq.com/sns/jscode2session',
            data:{
              appid: 'wx150fbac690c5859e',
              secret: '36c4ab0da49e4cca5a0dd43239c93712',
              grant_type:'authorization_code',
              js_code:res.code
            },
            method:'GET',
            header:{'ccontent-type':'application/json'},
            success:function(res){
              // this.globalData.openId = res.data.openId
                            console.log(res.data.openid)
            }
          })
        }else{

        }
      }
    })
  },
  globalData: {
    userInfo: null,
    openId:''
  }
})